<?php
	$question = $this->Question();
        $question->setReadOnlyAnswer(true);
        $question->setViewCorrectAnswer(true);
        $question->setViewStaticAnswer(true);
        $question->setIsShowAnswer(false);
	$question->setExam($this->exam);
	echo $question->render();
?>
<script type="text/javascript">
    en4.core.runonce.add(function() {
	  //$$('.exam_question_content').addClass('sortable');
      SortablesInstance = new Sortables($$('.exam_list_questions'), {
        clone: true,
        constrain: false,
        //handle: 'span',
        onComplete: function(e) {
          var ids = [];
          $$('.exam_question_content').each(function(el) {
            ids.push(el.get('id').match(/\d+/)[0]);
          });
          //console.log(ids);

          // Send request
          var url = '<?php echo $this->url(array('action' => 'order-question')) ?>';
          var request = new Request.JSON({
            'url' : url,
            'data' : {
              format : 'json',
              order : ids
            }
          });
          request.send();
		  
		  loadQuestions(<?php echo $this->exam->getIdentity()?>);
        }
      });
});
</script>